package com.fr.report.web.ui;

import com.fr.base.StringUtils;
import com.fr.base.core.ComparatorUtils;
import com.fr.base.core.json.JSONException;
import com.fr.base.core.json.JSONObject;
import com.fr.base.xml.XMLPrintWriter;
import com.fr.base.xml.XMLableReader;
import com.fr.web.Repository;

public class ComboCheckBox extends ComboBox
{
  public static final String COMMA = ",";
  public static final String SEMICOLON = ";";
  public static final String COLON = ":";
  public static final String NEWLINE = "\\r";
  public static final String DOUBLE_QUOTES = "\"";
  public static final String SINGLE_QUOTE = "'";
  private String delimiter = ",";
  private String startSymbol = "";
  private String endSymbol = "";
  private boolean returnArray = true;

  public String getDelimiter()
  {
    return this.delimiter;
  }

  public void setDelimiter(String paramString)
  {
    this.delimiter = paramString;
  }

  public String getStartSymbol()
  {
    return this.startSymbol;
  }

  public void setStartSymbol(String paramString)
  {
    this.startSymbol = paramString;
  }

  public String getEndSymbol()
  {
    return this.endSymbol;
  }

  public void setEndSymbol(String paramString)
  {
    this.endSymbol = paramString;
  }

  public boolean isReturnArray()
  {
    return this.returnArray;
  }

  public void setReturnArray(boolean paramBoolean)
  {
    this.returnArray = paramBoolean;
  }

  public String getXType()
  {
    return "combocheckbox";
  }

  public JSONObject createJSONConfig(Object paramObject, Repository paramRepository)
    throws JSONException
  {
    JSONObject localJSONObject = super.createJSONConfig(paramObject, paramRepository);
    if (!(StringUtils.isEmpty(this.delimiter)))
      localJSONObject.put("delimiter", this.delimiter);
    if (this.returnArray)
      localJSONObject.put("returnArray", true);
    if (!(StringUtils.isEmpty(this.startSymbol)))
      localJSONObject.put("startSymbol", this.startSymbol);
    if (!(StringUtils.isEmpty(this.endSymbol)))
      localJSONObject.put("endSymbol", this.endSymbol);
    return localJSONObject;
  }

  public void readXML(XMLableReader paramXMLableReader)
  {
    super.readXML(paramXMLableReader);
    if ((paramXMLableReader.isChildNode()) && (paramXMLableReader.getTagName().equals("RAAttr")))
    {
      this.returnArray = false;
      if (paramXMLableReader.getAttr("delimiter") != null)
        this.delimiter = paramXMLableReader.getAttr("delimiter");
      if (paramXMLableReader.getAttr("start") != null)
        this.startSymbol = paramXMLableReader.getAttr("start");
      if (paramXMLableReader.getAttr("end") != null)
        this.endSymbol = paramXMLableReader.getAttr("end");
    }
  }

  public void writeXML(XMLPrintWriter paramXMLPrintWriter)
  {
    super.writeXML(paramXMLPrintWriter);
    if (!(this.returnArray))
    {
      paramXMLPrintWriter.startTAG("RAAttr").attr("isArray", this.returnArray);
      if (!(",".equals(this.delimiter)))
        paramXMLPrintWriter.attr("delimiter", this.delimiter);
      if (!(StringUtils.isEmpty(this.startSymbol)))
        paramXMLPrintWriter.attr("start", this.startSymbol);
      if (!(StringUtils.isEmpty(this.endSymbol)))
        paramXMLPrintWriter.attr("end", this.endSymbol);
      paramXMLPrintWriter.end();
    }
  }

  public boolean equals(Object paramObject)
  {
    return ((paramObject instanceof ComboCheckBox) && (ComparatorUtils.equals(this.delimiter, ((ComboCheckBox)paramObject).delimiter)) && (this.returnArray == ((ComboCheckBox)paramObject).returnArray) && (super.equals(paramObject)));
  }
}